/**
菲波那切数列
*/
package main

import "fmt"

func main() {
	for i := 0; i <= 10; i++ {
		fmt.Printf("fib(%d): %d\n", i, fib(i))
	}
}

func fib(n int) int {
	m := make(map[int]int)
	m[0], m[1] = 1, 1
	if n <= 1 {
		return 1
	}

	for i := 2; i < n; i++ {
		m[i] = m[i-1] + m[i-2]
	}

	return m[n-1]
}
